// config
window.APP = { version : 'v=20170509' };

angular.module('app')
  .config(['$controllerProvider', '$compileProvider', '$filterProvider', '$provide',
	    function ($controllerProvider,   $compileProvider,   $filterProvider,   $provide) {
	        // lazy controller, directive and service
	        app.controller = $controllerProvider.register;
	        app.directive  = $compileProvider.directive;
	        app.filter     = $filterProvider.register;
	        app.factory    = $provide.factory;
	        app.service    = $provide.service;
	        app.constant   = $provide.constant;
	        app.value      = $provide.value;
	    }
	])
	.config(function(){
        jQuery.validator.setDefaults({
            errorClass: 'help-block animation-slideDown', // You can change the animation class for a different entrance animation - check animations page
            errorElement: 'div',
            errorPlacement: function(error, e) {
                var eleErrContains = e.parents('.tdgroup');
                if(eleErrContains.length == 0){
                    eleErrContains = e.parents('.form-group > div');
                }
                eleErrContains.append(error);
            },
            highlight: function(e) {
                $(e).closest('.form-group').removeClass('has-success has-error').addClass('has-error');
                $(e).closest('.help-block').remove();
            },
            success: function(e) {
                e.closest('.form-group').removeClass('has-success has-error');
                e.closest('.help-block').remove();
            }
        });
        $.extend({'cookie':function(name, value, options) {
                if(cookieIsEnable){
                    if (typeof value != 'undefined') { // name and value given, set cookie
                        options = options || {};
                        if (value === null) {
                            value = '';
                            options.expires = -1;
                        }
                        var expires = '';
                        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
                            var date;
                            if (typeof options.expires == 'number') {
                                date = new Date();
                                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
                            } else {
                                date = options.expires;
                            }
                            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
                        }
                        var path = options.path ? '; path=' + options.path : '';
                        var domain = options.domain ? '; domain=' + options.domain : '';
                        var secure = options.secure ? '; secure' : '';
                        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
                    } else { // only name given, get cookie
                        var cookieValue = null;
                        if (document.cookie && document.cookie != '') {
                            var cookies = document.cookie.split(';');
                            for (var i = 0; i < cookies.length; i++) {
                                var cookie = jQuery.trim(cookies[i]);
                                // Does this cookie string begin with the name we want?
                                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                                    break;
                                }
                            }
                        }
                        return cookieValue;
                    }
                }else{
                    alert('cookie 禁用');
                }
                function cookieIsEnable(){
                    return window.navigator.cookieEnabled;
                }
            }
        });
        jQuery.validator.addMethod('stringCheck',function(value,element){
        	return this.optional(element)||/^[a-zA-Z0-9\u4e00-\u9fa5]*$/.test(value);
        },'只能包含字母、数字和汉字');
        jQuery.validator.addMethod('isPhone',function(value,element){
        	var mobileRgx = /^1[3-8][0-9]\d{8}$/;
        	var telRgx =  /^(\d{3,4}-){0,1}\d{7,9}$/;
        	return this.optional(element)||mobileRgx.test(value)||telRgx.test(value);
        },'请输入正确格式的手机或电话号码');
        jQuery.validator.addMethod('isExist',function(value,element,params){
        	var isTrue = false;
        	jQuery.ajax({
        		url:params[0],
        		type:'GET',
        		async:false,
        		data:{
                    userId:params[1],
                    param:value
                },
        		dataType:'json',
        		success:function(resData){
        			isTrue = resData.success;
        		}
        	});
        	return this.optional(element)||isTrue;
        });
        jQuery.validator.addMethod('maxLengthB',function(value,element,params){
        	var b=0,l=value.length;
        	for(var i=0;i<l;i++){
        		if(value.charCodeAt(i)>255){
        			b+=2;
        		}else{
        			b++;
        		}
        	}
        	return this.optional(element)||b<=params[0];
        });
    })
    .config(['$ocLazyLoadProvider', function($ocLazyLoadProvider) {
      // We configure ocLazyLoad to use the lib script.js as the async loader
      $ocLazyLoadProvider.config({
          debug:false,
          events: true,
          modules: [{
              name: 'toaster',
              files: [
                  'lib/angular/toaster.js',
                  'lib/angular/toaster.css'
              ]
          }]
      });
    }])
    .filter('label', function() { // 显示为标签
		  return function(input, s) {
              var r = '';
              if(input!=null){
			  var l = input.split(s);
			  for(var i=0; i<l.length; i++) {
				  r += '<label class="label label-info">' + l[i] + '</label>\n';
			  }
              }
			  return r;
		  }
    })
    .filter('trustHtml', function ($sce) { // 安全HTML
        return function (input) {
            return $sce.trustAsHtml(input);
        }
    })
    .directive('uiNav', ['$timeout', function($timeout) {
    return {
      restrict: 'AC',
      link: function(scope, el, attr) {
        var _window = $(window), 
        _mb = 768, 
        wrap = $('.app-aside'), 
        next, 
        backdrop = '.dropdown-backdrop';
        // unfolded
        el.on('click', 'a', function(e) {
          next && next.trigger('mouseleave.nav');
          var _this = $(this);
          _this.parent().siblings( ".active" ).toggleClass('active');
          _this.next().is('ul') &&  _this.parent().toggleClass('active') &&  e.preventDefault();
          // mobile
          _this.next().is('ul') || ( ( _window.width() < _mb ) && $('.app-aside').removeClass('show off-screen') );
        });

        // folded & fixed
        el.on('mouseenter', 'a', function(e){
          next && next.trigger('mouseleave.nav');
          $('> .nav', wrap).remove();
          if ( !$('.app-aside-fixed.app-aside-folded').length || ( _window.width() < _mb ) || $('.app-aside-dock').length) return;
          var _this = $(e.target)
          , top
          , w_h = $(window).height()
          , offset = 50
          , min = 150;

          !_this.is('a') && (_this = _this.closest('a'));
          if( _this.next().is('ul') ){
             next = _this.next();
          }else{
            return;
          }
         
          _this.parent().addClass('active');
          top = _this.parent().position().top + offset;
          next.css('top', top);
          if( top + next.height() > w_h ){
            next.css('bottom', 0);
          }
          if(top + min > w_h){
            next.css('bottom', w_h - top - offset).css('top', 'auto');
          }
          next.appendTo(wrap);

          next.on('mouseleave.nav', function(e){
            $(backdrop).remove();
            next.appendTo(_this.parent());
            next.off('mouseleave.nav').css('top', 'auto').css('bottom', 'auto');
            _this.parent().removeClass('active');
          });

          $('.smart').length && $('<div class="dropdown-backdrop"/>').insertAfter('.app-aside').on('click', function(next){
            next && next.trigger('mouseleave.nav');
          });

        });

        wrap.on('mouseleave', function(e){
          next && next.trigger('mouseleave.nav');
          $('> .nav', wrap).remove();
	        });
	      }
	    };
	}])
	.directive('hasPermission', function() {  
	  return {
        restrict:'A',
	    link: function(scope, element, attrs) {  
	    	  var permissionList =sessionStorage.getItem('permissionList')
              // console.log( permissionList)
	    		if(permissionList&&permissionList.indexOf(attrs.permission)==-1){
                     element.hide()
	    		}
	    	    if(permissionList&&permissionList.indexOf(attrs.permission)!=-1){
	    	    	element.show()
	    		}
	    },
	    controller:['$scope',function($scope){
	    }]
	  };  
})
    .directive("upLoad",["$parse",function($parse){
        return{
            restrict: 'AE',
            replace:true,
            transclude:true,
            scope:{
                data:'=',
                ratios:'@ratio',
                format:'@'
            },
            template:"<div ng-transclude></div>",
            controller:['$scope', '$rootScope','fileReader','ajaxRquestImg',function($scope, $rootScope,fileReader,ajaxRquestImg){
                $scope.alertModel=function(value){
                    $rootScope.alertModel({
                        text:value, //内容
                        btnCancel:false, //取消按钮
                        btnConfirm:true, //确认按钮
                        resCode:'00001'
                    })
                };
                $rootScope.imgStyle="";
                $rootScope.multiResult=[];//将最终结果挂载到根作用域
                $scope.data=[]; //将每个上传视图结果挂载到局部作用域
                $scope.imgNumber=0
                $scope.$watch("data",function(){
                    if($scope.data.length==0){
                        $scope.imgNumber=0
                    }
                    $rootScope.multiResult.push($scope.data);
                });
                // sessionStorage.removeItem('multiResult')
                $scope.onOff=true
                $rootScope.$watch('multiResult',function(newValue){
                    if($rootScope.multiResult[0]&&$rootScope.multiResult[0][0]&&$scope.onOff){
                        $scope.onOff=false
                        var obj={}
                        obj.src=$rootScope.multiResult[0][0].src
                        $scope.data.push(obj)
                        $rootScope.multiResult[0]=$scope.data;
                    }
                });
                $scope.upLoadImg=function(result){
                    result=result.replace('image/jpeg','image/jpg')
                    ajaxRquestImg.getData('/upload/imageData',{
                        'fileData':result
                    }).then(function(res){
                        // if(res.httpCode=='200'){
                            $scope.$apply(function(){
                                $scope.imgSrc=res;
                                $scope.data.push({
                                    src:$scope.imgSrc
                                });
                            })
                        // }else{
                        //     console.log(res)
                        //     $scope.imgNumber--
                        //     $scope.alertModel({
                        //         text:res.msg, //内容
                        //         resCode:res.resCode
                        //     })
                        // }
                    })
                };
                $scope.checkImgSize=function(result){
                    if($scope.ratios){
                        if($scope.ratios.indexOf(':')!=-1){

                            $scope.ratiosArr=$scope.ratios.split(':')


                        }else if($scope.ratios.indexOf('：')!=-1){

                            $scope.ratiosArr=$scope.ratios.split('：')

                        }else if($scope.ratios.indexOf('*')!=-1){

                            $scope.ratiosArr=$scope.ratios.split('*')

                        }else if($scope.ratios.indexOf('*')!=-1){

                            $scope.ratiosArr=$scope.ratios.split('*')

                        }else if($scope.ratios.indexOf('x')!=-1){

                            $scope.ratiosArr=$scope.ratios.split('x')

                        }
                    }
                    var image = new Image();
                    image.src =result;
                    image.onload=function(){
                        var height = image.height;
                        var width = image.width;
                        if($scope.ratios){
                            if(parseInt($scope.ratiosArr[0])!=width||parseInt($scope.ratiosArr[1])!=height){
                                $scope.alertModel('请上传比例为'+$scope.ratios+'的图片')
                                $scope.imgNumber--
                                $scope.isRightRatio=false;
                            }else{
                                $scope.isRightRatio=true;
                            }
                        }
                        if($scope.ratios&&$scope.isRightRatio){
                            $scope.upLoadImg(result);
                        }else if(!$scope.ratios){
                            $scope.upLoadImg(result);
                        }
                    }
                }
                $scope.getFile = function () {
                    if(fileReader){
                        fileReader.readAsDataUrl($scope.file, $scope)
                            .then(function(result) {
                                $scope.checkImgSize(result)
                            });
                    }else{
                    $scope.alertModel('对不起！您的浏览器版本过低，请使用高版本浏览器');
                }
            };
        }],
        link:function(scope, element, attrs,$rootScope){
            scope.inputElement = element.find('input');
            scope.inputElement.bind('change', imgupload);
            function imgupload(event){
                scope.multi=attrs.multi;
                if(scope.multi<=scope.imgNumber){
                    return false
                }
                scope.imgNumber++
                scope.obj=element;
                scope.size=attrs.size;
                //附件预览
                if(event.dataTransfer){
                    scope.file= event.dataTransfer.files[0];
                }else{
                    scope.file = (event.srcElement || event.target).files[0];
                }
                if(!/.(gif|jpg|jpeg|png|GIF|JPG|png)$/.test(scope.file.type)){
                    scope.alertModel('图片格式不正确');
                    this.value="";
                    scope.imgNumber--
                    return false;
                }
                if(!scope.size&&scope.file.size>100000){
                    scope.alertModel('图片大小超过限制');
                    this.value="";
                    scope.imgNumber--
                    return false;
                }
/*
                if(scope.size&&scope.file.size>scope.size*1000){
                    scope.alertModel('图片超过限制');
                    this.value="";
                    scope.imgNumber--
                    return false;
                }*/
                scope.getFile();
                this.value="";
            }
            element[0].onclick=function(e){
                var el=e||window.event;
                var target=el.target||el.srcElement
                if(target.nodeName.toLowerCase()=='span'){
                    var index=$(target).attr('index');
                    scope.$apply(function(){
                        scope.data.splice(index,1);
                        scope.imgNumber--
                    })
                }
            }

            var dropbox=element[0];
            dropbox.addEventListener("dragenter", function(e){
                e.stopPropagation();
                e.preventDefault();
            }, false);
            dropbox.addEventListener("dragover", function(e){
                e.stopPropagation();
                e.preventDefault();
            }, false);
            dropbox.addEventListener("drop", function(e){
                e.stopPropagation();
                e.preventDefault();
                if(attrs.draggable){
                    imgupload(e);
                }
            }, false);
        }
    }
}])
    .directive("upHuiload",["$parse",function($parse){
        return{
            restrict: 'AE',
            scope:{
                data:'=',
                ratios:'@ratio'
            },
            controller:['$scope', '$rootScope','fileReader','ajaxRquestImg',function($scope, $rootScope,fileReader,ajaxRquestImg){
                $scope.alertModel=function(value){
                    $rootScope.alertModel({
                        text:value, //内容
                        btnCancel:false, //取消按钮
                        btnConfirm:true, //确认按钮
                        resCode:'00001'
                    })
                };
                $rootScope.imgStyle="";
                $rootScope.multiResult=[];//将最终结果挂载到根作用域
                $scope.data=[]; //将每个上传视图结果挂载到局部作用域
                $scope.imgNumber=0
                $scope.$watch("data",function(){
                    $rootScope.multiResult.push($scope.data);

                });
                // sessionStorage.removeItem('multiResult')
                $scope.onOff=true
                $rootScope.$watch('multiResult',function(newValue){
                    if($rootScope.multiResult[0]&&$rootScope.multiResult[0][0]&&$scope.onOff){
                        $scope.onOff=false
                        var obj={}
                        obj.src=$rootScope.multiResult[0][0].src
                        $scope.data.push(obj)

                        $rootScope.multiResult[0]=$scope.data;
                    }
                });

                $scope.upLoadImgHui=function(result){
                    ajaxRquestImg.getData('/upload/uploadImgHui',{
                        'fileData':result
                    }).then(function(res){
                        console.log(res)
                        if(res){
                            $scope.$apply(function(){
                                $scope.imgSrc = res;
                                console.log($scope.imgSrc)
                                $scope.checkImgSizeHui();
                            })
                        }else{
                            $scope.imgNumber--
                            /*$rootScope.alertModel({
                             text:res.msg, //内容
                             resCode:res.httpCode
                             })*/
                        }
                    })
                };

                $scope.checkImgSizeHui=function(){
                    if($scope.ratios){
                        var arr=$scope.ratios.split(":");
                        $scope.ratio=Number(arr[0])/Number(arr[1]);
                    }
                    var image = new Image();
                    image.src = $scope.imgSrc;
                    image.onload=function(){
                        var height = image.height;
                        var width = image.width;

                        if($scope.ratio&&(width/height/$scope.ratio!==1)){
                            $scope.alertModel('请上传比例为'+$scope.ratios+'的图片')
                            $scope.imgNumber--
                            $scope.isRightRatio=false;
                        }else{
                            $scope.isRightRatio=true;
                        }
                        if($scope.ratio&&$scope.isRightRatio){
                            $scope.$apply(function(){
                                $scope.data.push({
                                    src:$scope.imgSrc
                                });
                            })
                        }else if(!$scope.ratio){
                            $scope.$apply(function(){
                                $scope.data.push({
                                    src:$scope.imgSrc
                                });
                            })
                        }
                    }
                }
                $scope.getFileHui = function () {
                    if(fileReader){
                        fileReader.readAsDataUrl($scope.file, $scope)
                            .then(function(result) {
                                $scope.upLoadImgHui(result);
                            });
                    }else{
                        $scope.alertModel('对不起！您的浏览器版本过低，请使用高版本浏览器');
                    }
                };
            }],
            link:function(scope, element, attrs,$rootScope){
                scope.inputElement = element.find('input');
                scope.inputElement.bind('change', imguploadHui);
                function imguploadHui(event){
                    scope.multi=attrs.multi;
                    if(scope.multi<=scope.imgNumber){
                        return false
                    }
                    scope.imgNumber++
                    scope.obj=element;
                    scope.size=attrs.size;
                    //附件预览
                    if(event.dataTransfer){
                        scope.file= event.dataTransfer.files[0];
                    }else{
                        scope.file = (event.srcElement || event.target).files[0];
                    }
                    if(!/.(gif|jpg|jpeg|png|GIF|JPG|png)$/.test(scope.file.type)){
                        scope.alertModel('图片格式不正确');
                        this.value="";
                        scope.imgNumber--
                        return false;
                    }
                    if(!scope.size&&scope.file.size>100000){
                        scope.alertModel('图片大小超过限制');
                        this.value="";
                        scope.imgNumber--
                        return false;
                    }

                    if(scope.size&&scope.file.size>scope.size*1000){
                        scope.alertModel('图片大小超过限制');
                        this.value="";
                        scope.imgNumber--
                        return false;
                    }
                    scope.getFileHui();
                    this.value="";
                }
                element[0].onclick=function(e){
                    var el=e||window.event;
                    var target=el.target||el.srcElement
                    if(target.nodeName.toLowerCase()=='span'){
                        var index=$(target).attr('index');
                        scope.$apply(function(){
                            scope.data.splice(index,1);
                            scope.imgNumber--
                        })
                    }
                }

                var dropbox=element[0];
                dropbox.addEventListener("dragenter", function(e){
                    e.stopPropagation();
                    e.preventDefault();
                }, false);
                dropbox.addEventListener("dragover", function(e){
                    e.stopPropagation();
                    e.preventDefault();
                }, false);
                dropbox.addEventListener("drop", function(e){
                    e.stopPropagation();
                    e.preventDefault();
                    if(attrs.draggable){
                        imguploadHui(e);
                    }
                }, false);
            }
        }
    }])
.factory('fileReader', ["$q", "$log", function($q, $log){
    var onLoad = function(reader, deferred, scope) {
        return function () {
            scope.$apply(function () {
                deferred.resolve(reader.result);
            });
        };
    };

    var onError = function (reader, deferred, scope) {
        return function () {
            scope.$apply(function () {
                deferred.reject(reader.result);
            });
        };
    };

    var getReader = function(deferred, scope) {
        var reader = new FileReader();
        reader.onload = onLoad(reader, deferred, scope);
        reader.onerror = onError(reader, deferred, scope);
        return reader;
    };

    var readAsDataURL = function (file, scope) {
        var deferred = $q.defer();
        var reader = getReader(deferred, scope);
        reader.readAsDataURL(file);
        return deferred.promise;
    };
    return {
        readAsDataUrl: readAsDataURL
    };
}])
 .service("ajaxRquestImg",["$q","$http",function($q,$http){
        function loadingMessage(str) {
            var html = '<div class="loadingMessage" style="bottom: 100px; position: fixed; text-align: center; width: 100%; display:none; z-index:100000;"><font style="background-color: rgba(0, 0, 0, 0.7); border-radius: 5px; color: #fff; z-index:1000; display: inline-table; line-height: 170%; max-width: 80%; padding: 5px 10px;font-size:14px">'+ str +'</font></div>';
            $("body").append(html);
            $("body .loadingMessage").fadeIn("normal")
        }
        function hideLoading(){
            $("body .loadingMessage").fadeOut("normal",function(){
                $(this).remove();
            })
        }

        this.getData=function(url,params,method){
            url = "/eShopKeeper-SYS-Web" + url;
            if(method==undefined||method==""||method=="undefined"){
                var method='POST';
            }
            var secret='7$T5rcaOjA35bKoy&*dBbQS^ZPUsMDJj';
            function ajax(){
                var dtd = $.Deferred(); // 新建一个Deferred对象
                loadingMessage("图片上传中...");
                $.ajax({
                    url : url,
                    data: params
                }).then(function(result) {
                    console.log(result);
                    hideLoading();
                    var msg = result.imgName;
                    dtd.resolve(msg);
                },function(result){
                    hideLoading();
                    var msg = result.imgName;
                    dtd.reject(msg);
                });
                return dtd.promise();
            }
            return $.when(ajax());
        };
    }])
    .directive("mySelect2",function(){
        return {
            restrict: 'E',
            replace:true,
            transclude:true,
            scope:{
                datadefault:"=",
                defaultid:"=",
                defaultname:"@",
                dataout:"=",
                datain:"@",
                change:"&"
            },
            template:"<div class='selectWrap' ng-transclude></div>",
            link:function(scope,elemet,attrs){
                var oUl=elemet[0].getElementsByTagName("ul")[0];

                document.body.onclick=function(e) {
                    var e = e || window.event; //浏览器兼容性
                    var elem = e.target || e.srcElement;
                    while (elem) { //循环判断至跟节点，防止点击的是div子元素
                        if (elem.className && elem.className.indexOf('select-normal')!=-1) {
                            return;
                        }
                        elem = elem.parentNode;
                    }
                    oUl.style.display='none';
                    scope.onOff=true
                }
                scope.input=elemet[0].getElementsByTagName("input");
                scope.freshData=function(){

                    oUl.style.top=window.getComputedStyle(scope.input[0],'height')+'px'
                    scope.onOff=true
                    scope.input[0].onclick=function(e){
                        if(scope.onOff){
                            oUl.style.display='block';
                            scope.onOff=!scope.onOff
                        }else{
                            oUl.style.display='none';
                            scope.onOff=!scope.onOff
                        }
                    }
                    // scope.input[0].onblur=function(){
                    //     // setTimeout(function(){
                    //     //     scope.onOff=!scope.onOff
                    //     //     oUl.style.display='none';
                    //     // },250)
                    // }

                }
            },
            controller:['$scope','$rootScope',function($scope,$rootScope){
                $scope.$watch('datain',function(v){
                    $scope.freshData();
                    $scope.input[0].value='';
                    $scope.dataout='';
                })

                $scope.resultList=[];
                $scope.resultText=[]
                this.getEl=function(data){
                    $scope.change()
                    var len=$scope.resultList.length;
                    if(len==0){
                        $scope.resultList.push(data.scope.value)
                        $scope.resultText.push(data.scope.text)
                    }else{
                        for(var i=0;i<len;i++){
                            if($scope.resultList[i]==data.scope.value){
                                $scope.resultList.splice(i,1)
                                $scope.resultText.splice(i,1)
                                break
                            }else if(i==len-1){
                                $scope.resultList.push(data.scope.value)
                                $scope.resultText.push(data.scope.text)
                                break
                            }
                        }
                    }
                    $scope.input[0].value=$scope.resultText.join(',');
                    $scope.dataout=$scope.resultList.join(',');
                }
            }]
        }
    })
    .directive('myOption2',function(){
        return {
            restrict: 'AE',
            require:'^mySelect2',
            replace:true,
            transclude:true,
            scope:{
                text:"@",
                value:"="
            },
            link:function(scope,elemet,attrs,ctrls){
                scope.sendData=function () {
                    ctrls.getEl({"el":elemet,"scope":scope});
                    var checked=elemet.find('input').attr('checked')
                    if(checked){
                        elemet.find('input').attr('checked',false)
                    }else{
                        elemet.find('input').attr('checked',true)
                    }
                }
            },
            controller:['$scope',function ($scope) {

            }],
            template:"<li ng-transclude ng-click='sendData()'></li>"
        }
    })
    .directive('ngVideo',function(){
    return {
        restrict: "E",
        replace: true,
        transclude: true,
        scope: {
            src: "="
        },
        link: function (scope, element, attrs) {
        },
        controller: ['$scope','$sce', function ($scope,$sce) {
            $scope.getFileExt=function (str)
            {
                var d=/\.[^\.]+$/.exec(str);
                if(d!=null){
                   return d[0].toLowerCase();
                }
            }
            if($scope.getFileExt($scope.src).indexOf('mp4')!=-1){
               $scope.isMp4=true
            }
            var url=$scope.src
            var html='';
            if($scope.isMp4){
                html+="<video controls  class='videoObj' style='width: 100%;'>"
                html+=" <source  src="+$scope.src+">"
                html+="</video>"
            }else{
                html+="<object  src="+url+" classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' type='application/x-shockwave-flash' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0' id='swf' type='application/x-shockwave-flash' name='swf1' class='videoObj' >"
                html+="<embed  swliveconnect='true' src="+url+"  allowfullscreen='true' quality='high'  loop='false'  FlashVars=''     type='application/x-shockwave-flash'  pluginspage='http://www.adobe.com/go/getflashplayer' align='middle' allowscriptaccess='always' type='application/x-shockwave-flash'></embed>"
                html+="<param name='movie' value="+url+" />"
                html+="</object>"
            }
            $('#videoWrap').html(html)
        }]
    }
  })
    .directive('animate',function(){
        return {
            restrict: "E",
            replace: true,
            transclude: true,
            link: function (scope, element, attrs) {
                function getStyle(obj,property){
                    return window.getComputedStyle?parseInt(window.getComputedStyle(obj,false)[property]):parseInt(obj.currentStyle[property]);
                };
                var timer=null;
                function startMOve(){
                    var  moveLR1=element[0].getElementsByTagName('span')[0];
                    var  contentBody=$('.app-content-body')[0];
                    var  width=getStyle(contentBody,'width');
                    var  selfWidth= getStyle(moveLR1,'width');
                    var  datW=0;
                    var  x=0,onOff=true;
                    clearInterval(timer);
                    timer=setInterval(function() {
                        datW=width-selfWidth;
                        if(x<=datW&&onOff){
                            x+=1
                        }
                        if(x<=datW&&!onOff){
                            x-=1
                        }
                        if(x>=datW){
                            onOff=false
                        }
                        if(x<=0){
                            onOff=true
                        }
                        moveLR1.style.transform='translateX('+x+'px)'
                        moveLR1.style.webkitTransform='translateX('+x+'px)'
                    }, 10)

                }
                startMOve();
                window.onresize=function () {
                    clearInterval(timer);
                    startMOve()
                }
            },
            template:'<div class="animateWrap"  style="position: relative;">'+
            '<span class="moveLR1" style="font-weight:800;font-size:18px;color:#ff6600;display:inline-block"><img style="width:50px;" class="logoRotate" src="./res/img/plat_logo.png">欢迎来到蜂巢&慧驿站后台管理系统</span>'+
            '</div>'
        }
    })

;